package com.hainingtong.user.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hainingtong.user.dto.group.DefaultGroup;
import com.hainingtong.user.dto.group.PhoneCodeGroup;
import com.hainingtong.user.dto.group.UsernamePasswordGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;


@ApiModel("用户名密码注册")
@Data
public class RegisterUserDto {
    @ApiModelProperty("用户昵称")
    @NotNull(groups = DefaultGroup.class, message = "昵称不能为空")
    @Length(groups = DefaultGroup.class, min = 1, max = 20, message = "昵称长度1~20个字符")
    String nickname;

    @ApiModelProperty("用户账号")
    @NotNull(groups = DefaultGroup.class, message = "账号不能为空")
    @Length(groups = UsernamePasswordGroup.class, min = 4, max = 20, message = "账号只能包含4~20个数字字母下划线")
    @Pattern(groups = PhoneCodeGroup.class, regexp = "1[3-9]\\d{9}", message = "手机号格式不正确")
    String principal;

    @ApiModelProperty("用户密码")
    @NotNull(groups = DefaultGroup.class, message = "密码不能为空")
    @Length(groups = {UsernamePasswordGroup.class, PhoneCodeGroup.class}, min = 6, max = 100, message = "密码长度6~50个字符")
    String credentials;

    // 无需前端传递，通过不同的注册类型在 Controller 里面写死
    // 通过这个注解  就不会显示在swagger3的文档中了
    @JsonIgnore
    String type;
}
